package com.tg.app.view;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.module.appcommon.R;
import com.tg.appcommon.android.ResourcesUtil;
import com.tg.appcommon.android.TGApplicationBase;

public class MsgCenterToast {

    private static Context mContext;
    private static Toast mToast;
    private static TextView msgtv;
    public static void show(Context context,String msg){
        if (mContext!=context){
            mToast=null;
        }
        if (mToast==null){
            View view= LayoutInflater.from(context).inflate(R.layout.layout_msgtoast,null);
            msgtv=view.findViewById(R.id.msgtv);
            mToast=new Toast(context);
            mToast.setDuration(Toast.LENGTH_SHORT);
            mToast.setGravity(Gravity.CENTER,0,0);
            mToast.setView(view);
            mContext = context;
        }
        msgtv.setText(msg);
        mToast.show();
    }

    public static void show(Context context,int resid){
        show(context, ResourcesUtil.getString(resid));
    }
}
